<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" pageEncoding="utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ include file="../../common/common.jsp" %>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>角色列表 - ${title }</title>
</head>
<link href="${ctx }/static/plugins/zTree_v3/css/zTreeStyle.css" rel="stylesheet"/>
<body
        <%@ include file="../../common/skin.jsp" %>
>
<%@ include file="../../common/head.jsp" %>
<%@ include file="../../common/menu.jsp" %>
<div class="J_content">
    <div class="mt20 plr20">
        <form action="${ctx }/information/trainingRegistration" id="queryForm" method="POST">
            <div class="J_toolsBar clearfix">
                <select name="state" class="t_text ml10" style="border-radius: 6px">
                    <option value="-1" selected>-是否回复-</option>
                    <option value="1" <c:if test="${courseCounselQueryDTO.state == '1'}">selected</c:if>>已回复
                    </option>
                    <option value="0" <c:if test="${courseCounselQueryDTO.state == '0'}">selected</c:if>>等待回复
                    </option>
                </select>
                <%--<input placeholder="请输入角色名称" type="text" name="name" value="${roleQueryDTO.name }"/>--%>
                <div class="t_button mgl30">
                    <a class="abtn red" href="javascript:myQuery();">
                        <i class="icon"></i>查询
                    </a>
                </div>
                <div class="t_label ml10">
                    记录数：<label style="color: red;" id="total">${page.totalCount }</label>
                </div>
                <%--          <div class="t_label">公司名称</div>
                          <div class="t_text ml10">
                              <input placeholder="请输入公司名称" type="text" name="companyName"
                                     value="${memberOfQueryDTO.companyName }"/>
                          </div>
                          <div class="t_label">手机号</div>
                          <div class="t_text ml10">
                              <input placeholder="请输入手机号" type="text" name="phone" value="${memberOfQueryDTO.phone }"/>
                          </div>
                          <div class="t_button mgl30">
                              <a class="abtn red" href="javascript:myQuery();">
                                  <i class="icon"></i>查询
                              </a>
                          </div>
                          <div class="t_button ml10">
                              <a class="abtn blue" href="javascript:myEdit();">
                                  <i class="icon"></i>新增
                              </a>
                          </div>--%>
            </div>
            <div class="J_table mt20">
                <div class="t_table">
                    <table>
                        <thead>
                        <tr>
                            <td>
                                <span>序号</span>
                            </td>
                            <td>
                                <span>课程名称</span>
                            </td>
                            <td>
                                <span>资询描述</span>
                            </td>
                            <td>
                                <span>联系人姓名</span>
                            </td>
                            <td>
                                <span>联系人号码</span>
                            </td>
                            <td>
                                <span>状态</span>
                            </td>
                            <td>
                                <span>创建时间</span>
                            </td>
                            <td>
                                <span>操作</span>
                            </td>
                        </tr>
                        </thead>
                        <tbody>
                        <c:choose>
                            <c:when test="${page.list != null && page.totalCount > 0 }">
                                <c:forEach items="${page.list }" var="r" varStatus="status">
                                    <tr>
                                        <td class="first">
                                            <div class="t_text tc">
                                                    ${status.index+1 }
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                    ${r.courseName}
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc" >
                                                <c:if test="${fn:length(r.text)<=17}">
                                                    ${r.text}
                                                </c:if>
                                                <c:if test="${fn:length(r.text)>17}">
                                                    ${fn:substring(r.text,0,17)}...
                                                </c:if>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                    ${r.linkName }
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                    ${r.linkNum }
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                    ${r.state == 0 ? "资询中" :"已完成" }
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_text tc">
                                                <fmt:formatDate value="${r.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="t_link">
                                                <a href="javascript:myEdit('${r.id }');"><i class="icon"></i>查看详情</a>
                                                <c:if test="${r.state == 0}">
                                                    <a href="javascript:reply('${r.id }');"><i class="icon"></i>回复</a>
                                                </c:if>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <tr>
                                    <td colspan="6">
                                        <div class="J_null mt40">
                                            <img src="${ctx }/static/images/null.png">
                                            <p>暂无相关数据</p>
                                        </div>
                                    </td>
                                </tr>
                            </c:otherwise>
                        </c:choose>
                        </tbody>
                    </table>
                </div>
                <%@ include file="../../common/pager.jsp" %>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="${ctx }/static/plugins/zTree_v3/js/jquery.ztree.all.min.js"></script>
<script type="text/javascript">
    <%--跳转页面到编辑页--%>
    function myEdit(id) {
        var loadIdx = layer.load();
        var title = '详情预览';
        $.post('${ctx}/information/trainingRegistration/edit?id=' + id, {}, function (str) {
            layer.close(loadIdx);
            layer.open({
                title: title,
                type: 1,
                area: ['600px', '600px'],
                content: str,
                btn: ['确定', '取消'],
                yes: function (index, layero) {
                    mySubmit();
                },
                btn2: function (index, layero) {
                    layer.close(index);
                }
            });
        });
    }
    function reply(id) {
        var loadIdx = layer.load();
        var title = "回复内容";
        var url = "/information/trainingRegistration/reply";
        $.post('${ctx}/information/reply?id=' + id + '&url=' + url, {}, function (str) {
            layer.close(loadIdx);
            layer.open({
                type: 1,
                area: ['600px', '400px'],
                content: str,
                btn: ['确定', '取消'],
                title: title,
                yes: function (index, layero) {
                    mySubmit();
                },
                btn2: function (index, layero) {
                    layer.close(index);
                }
            });
        });
    }

    function mySubmit() {
        $('#editForm').submit();
    }

    function myQuery() {
        $('#queryForm').submit();
    }
</script>
</body>
</html>